package com.sky.yipinyoufujava.result;
//统一的响应返回格式
public class Result {
    /**
     * @param code 响应码 1=成功 0=失败
     * @param msg  响应提示码  比如：操作失败....
     * @param data 数据
     */
    private Integer code;

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    private String msg;
    private Object data;
    public static Result success(Object data){
        return new Result(200, "success", data);
    }
    public static Result success(){
        return new Result(200, "success", null);
    }
    public static Result error(String msg){
        return new Result(500, msg, null);
    }
    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
